<?php
/*
 * ebiz front
 *
 * gifts Model
 *
 * @author allen
 *
 */
require_once '../app/core/models/BaseDao.php';
require_once '../app/core/db/DBUtil.class.php';

class GiftDao extends BaseDao
{
    private $tableName = "gifts";

    public function __construct($dbUtil){
        parent::__construct($dbUtil);
        $this->_name = $this->tableName;
    }
    
    public function getAllGiftsByAvailabilityTime($int_page, $int_limit){
    	$param = array();
        $sql="select * from $this->tableName 
        where start_date <= now() and end_date >= now() and is_delete=0
        limit {$int_page}, {$int_limit}
        ";
        return $this->dbUtil->SelectData($sql,$param);
    }
    
    public function getAllNum(){
    	$param = array();
        $sql="select count(*) as allNum from $this->tableName where start_date <= now() and end_date >= now() and is_delete=0 ";
        return $this->dbUtil->SelectData($sql,$param);
    }
    
    public function getGiftsById($id){
        $param = array($id);
        $sql="select * from $this->tableName 
        where id=? and start_date <= now() and end_date >= now() and is_delete=0 ";
        return $this->dbUtil->SelectData($sql,$param);
    }
    /**
     * 根据id查找gift信息,用于礼品详情
     */
    public function getGiftById($id){
        $param = array($id);
        $sql="select * from $this->tableName where id=? and is_delete=0 ";
        return $this->dbUtil->SelectData($sql,$param);  
    }

}




